package com.sparrow.common.log;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;

/**
 * 只允许带 Throwable 的日志通过
 * 用于 exception.log 的专用过滤器
 */
public class ThrowableOnlyFilter extends Filter<ILoggingEvent> {

    @Override
    public FilterReply decide(ILoggingEvent event) {
        // 如果日志中包含 Throwable，则接受，否则拒绝
        if (event.getThrowableProxy() != null) {
            return FilterReply.ACCEPT;
        }
        return FilterReply.DENY;
    }
}

